home *** CD-ROM | disk | FTP | other *** search
-
-
-
- GGGGRRRREEEEPPPP((((1111)))) GGGGNNNNUUUU PPPPrrrroooojjjjeeeecccctttt ((((1111999999992222 SSSSeeeepppptttteeeemmmmbbbbeeeerrrr 11110000)))) GGGGRRRREEEEPPPP((((1111))))
-
-
-
- NNNNAAAAMMMMEEEE
- grep, egrep, fgrep - print lines matching a pattern
-
- SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
- ggggrrrreeeepppp [-AB] num] [-CEFGVbchiLlnqsvwxyUu] [-e pattern | -f
- file] [--extended-regexp] [--fixed-strings] [--basic-regexp]
- [--regexp=PATTERN] [--file=FILE] [--ignore-case] [--word-
- regexp] [--line-regexp] [--line-regexp] [--no-messages] [--
- revert-match] [--version] [--help] [--byte-offset] [--line-
- number] [--with-filename] [--no-filename] [--quiet] [--
- silent] [--files-without-match] [--files-with-matcces] [--
- count] [--before-context=NUM] [--after-context=NUM] [--
- context] [--binary] [--unix-byte-offsets] _f_i_l_e_s...
-
- DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
- GGGGrrrreeeepppp searches the named input _f_i_l_e_s (or standard input if no
- files are named, or the file name ---- is given) for lines
- containing a match to the given _p_a_t_t_e_r_n. By default, ggggrrrreeeepppp
- prints the matching lines.
-
- There are three major variants of ggggrrrreeeepppp, controlled by the
- following options.
- ----GGGG,,,, --------bbbbaaaassssiiiicccc----rrrreeeeggggeeeexxxxpppp
- Interpret _p_a_t_t_e_r_n as a basic regular expression (see
- below). This is the default.
- ----EEEE,,,, --------eeeexxxxtttteeeennnnddddeeeedddd----rrrreeeeggggeeeexxxxpppp
- Interpret _p_a_t_t_e_r_n as an extended regular expression
- (see below).
- ----FFFF,,,, --------ffffiiiixxxxeeeedddd----ssssttttrrrriiiinnnnggggssss
- Interpret _p_a_t_t_e_r_n as a list of fixed strings, separated
- by newlines, any of which is to be matched.
- In addition, two variant programs eeeeggggrrrreeeepppp and ffffggggrrrreeeepppp are
- available. EEEEggggrrrreeeepppp is similar (but not identical) to ggggrrrreeeepppp ----EEEE,
- and is compatible with the historical Unix eeeeggggrrrreeeepppp. FFFFggggrrrreeeepppp is
- the same as ggggrrrreeeepppp ----FFFF.
-
- All variants of ggggrrrreeeepppp understand the following options:
- ----nnnnuuuummmm Matches will be printed with _n_u_m lines of leading and
- trailing context. However, ggggrrrreeeepppp will never print any
- given line more than once.
- ----AAAA nnnnuuuummmm ,,,, --------aaaafffftttteeeerrrr----ccccoooonnnntttteeeexxxxtttt====NNNNUUUUMMMM
- Print _n_u_m lines of trailing context after matching
- lines.
- ----BBBB nnnnuuuummmm ,,,, --------bbbbeeeeffffoooorrrreeee----ccccoooonnnntttteeeexxxxtttt====NNNNUUUUMMMM
- Print _n_u_m lines of leading context before matching
- lines.
- ----CCCC,,,, --------ccccoooonnnntttteeeexxxxtttt
- Equivalent to ----2222.
- ----VVVV,,,, --------vvvveeeerrrrssssiiiioooonnnn
- Print the version number of ggggrrrreeeepppp to standard error.
- This version number should be included in all bug
- reports (see below).
-
-
-
- Page 1 (printed 4/8/98)
-
-
-
-
-
-
- GGGGRRRREEEEPPPP((((1111)))) GGGGNNNNUUUU PPPPrrrroooojjjjeeeecccctttt ((((1111999999992222 SSSSeeeepppptttteeeemmmmbbbbeeeerrrr 11110000)))) GGGGRRRREEEEPPPP((((1111))))
-
-
-
- ----bbbb,,,, --------bbbbyyyytttteeee----ooooffffffffsssseeeetttt
- Print the byte offset within the input file before each
- line of output.
- ----cccc,,,, --------ccccoooouuuunnnntttt
- Suppress normal output; instead print a count of
- matching lines for each input file. With the ----vvvv,,,, --------
- rrrreeeevvvveeeerrrrtttt----mmmmaaaattttcccchhhh option (see below), count non-matching
- lines.
- ----eeee _p_a_t_t_e_r_n,,,,--_r_e_g_e_x_p=_P_A_T_T_E_R_N
- Use _p_a_t_t_e_r_n as the pattern; useful to protect patterns
- beginning with ----.
- ----ffff _f_i_l_e,,,,--_f_i_l_e=_F_I_L_E
- Obtain the pattern from _f_i_l_e.
- ----hhhh,,,, --------nnnnoooo----ffffiiiilllleeeennnnaaaammmmeeee
- Suppress the prefixing of filenames on output when
- multiple files are searched.
- ----iiii,,,, --------iiiiggggnnnnoooorrrreeee----ccccaaaasssseeee
- Ignore case distinctions in both the _p_a_t_t_e_r_n and the
- input files.
- ----LLLL,,,, --------ffffiiiilllleeeessss----wwwwiiiitttthhhhoooouuuutttt----mmmmaaaattttcccchhhh
- Suppress normal output; instead print the name of each
- input file from which no output would normally have
- been printed. The scanning will stop on the first
- match.
- ----llll,,,, --------ffffiiiilllleeeessss----wwwwiiiitttthhhh----mmmmaaaattttcccchhhheeeessss
- Suppress normal output; instead print the name of each
- input file from which output would normally have been
- printed. The scanning will stop on the first match.
- ----nnnn,,,, --------lllliiiinnnneeee----nnnnuuuummmmbbbbeeeerrrr
- Prefix each line of output with the line number within
- its input file.
- ----qqqq,,,, --------qqqquuuuiiiieeeetttt
- Quiet; suppress normal output. The scanning will stop
- on the first match.
- ----ssss,,,, --------ssssiiiilllleeeennnntttt
- Suppress error messages about nonexistent or unreadable
- files.
- ----vvvv,,,, --------rrrreeeevvvveeeerrrrtttt----mmmmaaaattttcccchhhh
- Invert the sense of matching, to select non-matching
- lines.
- ----wwww,,,, --------wwwwoooorrrrdddd----rrrreeeeggggeeeexxxxpppp
- Select only those lines containing matches that form
- whole words. The test is that the matching substring
- must either be at the beginning of the line, or
- preceded by a non-word constituent character.
- Similarly, it must be either at the end of the line or
- followed by a non-word constituent character. Word-
- constituent characters are letters, digits, and the
- underscore.
- ----xxxx,,,, --------lllliiiinnnneeee----rrrreeeeggggeeeexxxxpppp
- Select only those matches that exactly match the whole
- line.
-
-
-
- Page 2 (printed 4/8/98)
-
-
-
-
-
-
- GGGGRRRREEEEPPPP((((1111)))) GGGGNNNNUUUU PPPPrrrroooojjjjeeeecccctttt ((((1111999999992222 SSSSeeeepppptttteeeemmmmbbbbeeeerrrr 11110000)))) GGGGRRRREEEEPPPP((((1111))))
-
-
-
- ----yyyy Obsolete synonym for ----iiii.
- ----UUUU,,,, --------bbbbiiiinnnnaaaarrrryyyy
- Treat the file(s) as binary. By default, under MS-DOS
- and MS-Windows, ggggrrrreeeepppp guesses the file type by looking
- at the contents of the first 32KB read from the file.
- If ggggrrrreeeepppp decides the file is a text file, it strips the
- CR characters from the original file contents (to make
- regular expressions with ^^^^ and $$$$ work correctly).
- Specifying ----UUUU overrules this guesswork, causing all
- files to be read and passed to the matching mechanism
- verbatim; if the file is a text file with CR/LF pairs
- at the end of each line, this will cause some regular
- expressions to fail. This option is only supported on
- MS-DOS and MS-Windows.
- ----uuuu,,,, --------uuuunnnniiiixxxx----bbbbyyyytttteeee----ooooffffffffsssseeeettttssss
- Report Unix-style byte offsets. This switch causes
- ggggrrrreeeepppp to report byte offsets as if the file were Unix-
- style text file, i.e. with CR characters stripped off.
- This will produce results identical to running ggggrrrreeeepppp on
- a Unix machine. This option has no effect unless ----bbbb
- option is also used; it is only supported on MS-DOS and
- MS-Windows.
-
- RRRREEEEGGGGUUUULLLLAAAARRRR EEEEXXXXPPPPRRRREEEESSSSSSSSIIIIOOOONNNNSSSS
- A regular expression is a pattern that describes a set of
- strings. Regular expressions are constructed analogously to
- arithmetic expressions, by using various operators to
- combine smaller expressions.
-
- GGGGrrrreeeepppp understands two different versions of regular
- expression syntax: ``basic'' and ``extended.'' In
- GNU ggggrrrreeeepppp, there is no difference in available functionality
- using either syntax. In other implementations, basic
- regular expressions are less powerful. The following
- description applies to extended regular expressions;
- differences for basic regular expressions are summarized
- afterwards.
-
- The fundamental building blocks are the regular expressions
- that match a single character. Most characters, including
- all letters and digits, are regular expressions that match
- themselves. Any metacharacter with special meaning may be
- quoted by preceding it with a backslash.
-
- A list of characters enclosed by [[[[ and ]]]] matches any single
- character in that list; if the first character of the list
- is the caret ^^^^ then it matches any character _n_o_t in the
- list. For example, the regular expression [[[[0000111122223333444455556666777788889999]]]]
- matches any single digit. A range of ASCII characters may
- be specified by giving the first and last characters,
- separated by a hyphen. Finally, certain named classes of
- characters are predefined. Their names are self
-
-
-
- Page 3 (printed 4/8/98)
-
-
-
-
-
-
- GGGGRRRREEEEPPPP((((1111)))) GGGGNNNNUUUU PPPPrrrroooojjjjeeeecccctttt ((((1111999999992222 SSSSeeeepppptttteeeemmmmbbbbeeeerrrr 11110000)))) GGGGRRRREEEEPPPP((((1111))))
-
-
-
- explanatory, and they are [[[[::::aaaallllnnnnuuuummmm::::]]]], [[[[::::aaaallllpppphhhhaaaa::::]]]], [[[[::::ccccnnnnttttrrrrllll::::]]]],
- [[[[::::ddddiiiiggggiiiitttt::::]]]], [[[[::::ggggrrrraaaapppphhhh::::]]]], [[[[::::lllloooowwwweeeerrrr::::]]]], [[[[::::pppprrrriiiinnnntttt::::]]]], [[[[::::ppppuuuunnnncccctttt::::]]]],
- [[[[::::ssssppppaaaacccceeee::::]]]], [[[[::::uuuuppppppppeeeerrrr::::]]]], and [[[[::::xxxxddddiiiiggggiiiitttt::::]]]].... For example,
- [[[[[[[[::::aaaallllnnnnuuuummmm::::]]]]]]]] means [[[[0000----9999AAAA----ZZZZaaaa----zzzz]]]], except the latter form is
- dependent upon the ASCII character encoding, whereas the
- former is portable. (Note that the brackets in these class
- names are part of the symbolic names, and must be included
- in addition to the brackets delimiting the bracket list.)
- Most metacharacters lose their special meaning inside lists.
- To include a literal ]]]] place it first in the list.
- Similarly, to include a literal ^^^^ place it anywhere but
- first. Finally, to include a literal ---- place it last.
-
- The period .... matches any single character. The symbol \\\\wwww is
- a synonym for [[[[[[[[::::aaaallllnnnnuuuummmm::::]]]]]]]] and \\\\WWWW is a synonym for
- [[[[^^^^[[[[::::aaaallllnnnnuuuummmm]]]]]]]].
-
- The caret ^^^^ and the dollar sign $$$$ are metacharacters that
- respectively match the empty string at the beginning and end
- of a line. The symbols \\\\<<<< and \\\\>>>> respectively match the
- empty string at the beginning and end of a word. The symbol
- \\\\bbbb matches the empty string at the edge of a word, and \\\\BBBB
- matches the empty string provided it's _n_o_t at the edge of a
- word.
-
- A regular expression matching a single character may be
- followed by one of several repetition operators:
- ???? The preceding item is optional and matched at most
- once.
- **** The preceding item will be matched zero or more times.
- ++++ The preceding item will be matched one or more times.
- {{{{_n}}}} The preceding item is matched exactly _n times.
- {{{{_n,,,,}}}} The preceding item is matched _n or more times.
- {{{{,,,,_m}}}} The preceding item is optional and is matched at most _m
- times.
- {{{{_n,,,,_m}}}}
- The preceding item is matched at least _n times, but not
- more than _m times.
-
- Two regular expressions may be concatenated; the resulting
- regular expression matches any string formed by
- concatenating two substrings that respectively match the
- concatenated subexpressions.
-
- Two regular expressions may be joined by the infix operator
- ||||; the resulting regular expression matches any string
- matching either subexpression.
-
- Repetition takes precedence over concatenation, which in
- turn takes precedence over alternation. A whole
- subexpression may be enclosed in parentheses to override
- these precedence rules.
-
-
-
- Page 4 (printed 4/8/98)
-
-
-
-
-
-
- GGGGRRRREEEEPPPP((((1111)))) GGGGNNNNUUUU PPPPrrrroooojjjjeeeecccctttt ((((1111999999992222 SSSSeeeepppptttteeeemmmmbbbbeeeerrrr 11110000)))) GGGGRRRREEEEPPPP((((1111))))
-
-
-
- The backreference \\\\_n, where _n is a single digit, matches the
- substring previously matched by the _nth parenthesized
- subexpression of the regular expression.
-
- In basic regular expressions the metacharacters ????, ++++, {{{{, ||||,
- ((((, and )))) lose their special meaning; instead use the
- backslashed versions \\\\????, \\\\++++, \\\\{{{{, \\\\||||, \\\\((((, and \\\\)))).
-
- In eeeeggggrrrreeeepppp the metacharacter {{{{ loses its special meaning;
- instead use \\\\{{{{.
-
- DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
- Normally, exit status is 0 if matches were found, and 1 if
- no matches were found. (The ----vvvv option inverts the sense of
- the exit status.) Exit status is 2 if there were syntax
- errors in the pattern, inaccessible input files, or other
- system errors.
-
- BBBBUUUUGGGGSSSS
- Email bug reports to bbbbuuuugggg----ggggnnnnuuuu----uuuuttttiiiillllssss@@@@pppprrrreeeepppp....aaaaiiii....mmmmiiiitttt....eeeedddduuuu. Be sure
- to include the word ``grep'' somewhere in the ``Subject:''
- field.
-
- Large repetition counts in the {{{{_m,,,,_n}}}} construct may cause
- grep to use lots of memory. In addition, certain other
- obscure regular expressions require exponential time and
- space, and may cause ggggrrrreeeepppp to run out of memory.
-
- Backreferences are very slow, and may require exponential
- time.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Page 5 (printed 4/8/98)
-
-
-
-